home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000040_icon-group-sender _Fri Feb 11 10:19:55 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
4KB
Received: by cheltenham.cs.arizona.edu; Fri, 11 Feb 1994 12:08:42 MST
Date: Fri, 11 Feb 1994 10:19:55 -0600 (CST)
From: Chris Tenaglia - 257-8765 <TENAGLIA@MIS.MCW.EDU>
Subject: keynames
To: icon-group@cs.arizona.edu
Message-Id: <01H8R7KUZDDE8WXRXT@mis.mcw.edu>
Organization: Medical College of Wisconsin (Milwaukee, WI)
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Transfer-Encoding: 7BIT
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
I'm not Chinese, but I heard Chinese NewYear was this week. I don't
have a game to post to commemorate the holiday, but I do have something
that might turn out to be useful. I call it keyname. It's layered on
getch() and is easily modified. This program/routine was written for
PC, but it could probably be modified for other OSes too.
I thought it would be nice to get a name from a key strike rather than
just the raw control character(s). Under VMS BASIC the inkey$ function
actually returns the name of the key. Ascii characters for printables,
and names like F8 or PF3 or KP5. On the PC I found that there is no
distinction between numeric keypad 5 and typewriter 5. There is no
disctinction between edit keypad PgDn and numeric keypad PgDn, at least
as far as Icon getch() is concerned. In fact F11 and keypad 5 aren't
even detected. But still this routine can make the working keys return
names that can make a program more readible and easy to maintain. Enjoy!
Chris Tenaglia (System Manager) | "The past explained,
Medical College of Wisconsin | the future fortold,
8701 W. Watertown Plank Rd. | the present largely appologized for."
Milwaukee, WI 53226 | Organon to The Doctor
(414)257-8765 |
tenaglia@mis.mcw.edu
procedure main() # this main() tests the routine below
repeat
{
k := getch()
if k == "#" then break # permit clean escape
if k == "\000" then k ||:= getch()
write(image(k)," = ",keyname(k))
}
end
procedure keyname(str)
static keys
initial {
keys := table("ANY")
keys["\000;"] := "F1"
keys["\000<"] := "F2"
keys["\000="] := "F3"
keys["\000>"] := "F4"
keys["\000?"] := "F5"
keys["\000@"] := "F6"
keys["\000A"] := "F7"
keys["\000B"] := "F8"
keys["\000C"] := "F9"
keys["\000D"] := "F10"
keys["\000\373"] := "F12"
keys["\000H"] := "UPARROW"
keys["\000P"] := "DOWNARROW"
keys["\000M"] := "RIGHTARROW"
keys["\000K"] := "LEFTARROW"
keys["\000I"] := "PAGEUP"
keys["\000Q"] := "PAGEDOWN"
keys["\000G"] := "HOME"
keys["\000O"] := "END"
keys["\000R"] := "INSERT"
keys["\000S"] := "DELETE"
keys["\e"] := "ESCAPE"
keys["\001"] := "CTRL_A"
keys["\002"] := "CTRL_B"
keys["\003"] := "CTRL_C"
keys["\004"] := "CTRL_D"
keys["\005"] := "CTRL_E"
keys["\006"] := "CTRL_F"
keys["\007"] := "BELL"
keys["\010"] := "BACKSPACE"
keys["\011"] := "TAB"
keys["\012"] := "LINEFEED"
keys["\013"] := "CTRL_K"
keys["\014"] := "FORMFEED"
keys["\015"] := "RETURN"
keys["\016"] := "CTRL_N"
keys["\017"] := "CTRL_O"
keys["\020"] := "CTRL_P"
keys["\021"] := "CTRL_Q"
keys["\022"] := "CTRL_R"
keys["\023"] := "CTRL_S"
keys["\024"] := "CTRL_T"
keys["\025"] := "CTRL_U"
keys["\026"] := "CTRL_V"
keys["\027"] := "CTRL_W"
keys["\030"] := "CTRL_X"
keys["\031"] := "CTRL_Y"
keys["\032"] := "CTRL_Z"
}
return keys[str]
end